package regex;

/**
 * String[] split(String regex)
 *           根据给定正则表达式的匹配拆分此字符串。
 */
public class RegexDemo07 {
    public static void main(String[] args) {
       // method01();
        /**
         * IP地址:192.168.1.132
         */
        String ipStr = "192.168.1.132";
        String[] splitStrs = ipStr.split("\\.");
        for (int i = 0; i < splitStrs.length; i++) {
            System.out.println(splitStrs[i]);
        }
    }

    /**
     * 切割单词
     */
    private static void method01() {
        String str = "I    love      java so much";
        String regexStr = " +";//代表空格出现1次或多次
        String[] splitStrs = str.split(regexStr);
        for (int i = 0; i < splitStrs.length; i++) {
            System.out.println(splitStrs[i]);
        }
    }
}
